package com.exrobot.module.rbt.enums;

import com.exrobot.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum RbtAddressTypeEnum implements ArrayValuable<String> {
    // ========== 机器人任务类型 ==========
    MEMBER("member", "客户"),
    CANTEEN("canteen", "食堂"),
    WAIT_POINT("wait_point", "待命点"),
    OPERATION_POINT("operation_point","运维点")
    ;

    /**
     * 类型值
     */
    private final String val;
    /**
     * 类型名
     */
    private final String name;

    public static final String[] ARRAYS = Arrays.stream(values()).map(RbtAddressTypeEnum::getVal).toArray(String[]::new);

    public static RbtAddressTypeEnum validateVal(String val) {
        for (RbtAddressTypeEnum typeEnum : RbtAddressTypeEnum.values()) {
            if (typeEnum.getVal().equals(val)) {
                return typeEnum;
            }
        }
        throw new IllegalArgumentException("非法类型： " + val);
    }

    public static String getName(String val) {
        for (RbtAddressTypeEnum typeEnum : RbtAddressTypeEnum.values()) {
            if (typeEnum.getVal().equals(val)) {
                return typeEnum.name;
            }
        }
        return "未知";
    }

    @Override
    public String[] array() {
        return ARRAYS;
    }
}
